const jwt = require("jsonwebtoken");

const { jwtConfig } = require("../config/application.config");

const { jwtSecretKey, expires } = jwtConfig;

const JWT = {
  generate(value) {
    return jwt.sign(value, jwtSecretKey, {
      expiresIn: expires,
    });
  },
  verify(token) {
    try {
      return jwt.verify(token, jwtSecretKey);
    } catch (error) {
      return false;
    }
  },
};

module.exports = JWT;
